<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>立项审计</title>
  <link rel="stylesheet" href="/plug-in/layui/css/layui.css" media="all"> 
</head>
<body style="padding: 5px;">
<div class="headForm">
	<form class="layui-form" lay-filter="" id="headForm">
	  <div class="layui-form-item">
	   <div class="layui-inline">
	     <label class="layui-form-label">项目编号</label>
	     <div class="layui-input-inline">
	       <input type="text" name="pNo" autocomplete="off" disabled class="layui-input" />
	     </div>
	   </div>
	   <div class="layui-inline">
	     <label class="layui-form-label">项目名称</label>
	     <div class="layui-input-inline">
	       <input type="text" name="pName" autocomplete="off" disabled class="layui-input" />
	     </div>
	   </div>
	   <div class="layui-inline">
	     <label class="layui-form-label">合同编号</label>
	     <div class="layui-input-inline">
	       <input type="text" name="contractNo" autocomplete="off" disabled class="layui-input" />
	     </div>
	   </div>
	   <div class="layui-inline">
	     <div class="layui-input-inline">
	       <div class="layui-btn-group demoTable" id="tableBtn">
	       	<button lay-submit lay-filter="pForm" class="layui-btn">刷新</button>
	       </div>
	     </div>
	   </div>
	 </div>
	</form>
</div>
<div class="layui-tab layui-tab-brief">
  <ul class="layui-tab-title">
    <li class="layui-this">工程信息</li>
    <li>施工信息</li>
    <li>审计数据</li>
  </ul>
  <div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
    	<!-- 立项工程信息表单 -->
    	<%@ include file="form_project.jsp" %>
    </div>
    <div class="layui-tab-item">
    	<%@ include file="form_work_information_view.jsp" %>
    </div>
    <div class="layui-tab-item">
    	<%@ include file="form_check.jsp" %>
    </div>
  </div>
</div>
 <script src="/plug-in/layui/layui.js"></script>
<script>
//注意：选项卡 依赖 element 模块，否则无法进行功能性操作
layui.config({ base: '/plug-in/build/'}).use(['element','form','pForm','laydate','jquery'], function(){
  var element = layui.element;
  var pForm = layui.pForm;
  var laydate = layui.laydate;
  var $ = layui.jquery;
  var projectRow = pForm.rowData ;
  
  laydate.render({  elem: 'input[name=startDate]'});  
  laydate.render({  elem: 'input[name=endDate]'});  
  laydate.render({  elem: 'input[name=checkDate]'});  
  /*加载头部表单信息*/
  pForm.loadData({formId:'headForm'});
  
  /*加载工程表单信息*/
  pForm.loadData({formId:'projectForm'});
  
  pForm.addSubmitEvent({
	  submitLayFilter:'btnWorkAdd',
	  url: '/console/com.fs.jzzn.pojo.Audit/newAdd'
  });
  
  /*异步获取施工信息*/
  $.get('/console/com.fs.jzzn.pojo.Information/json', {
	  pNo: projectRow.pNo,
	  pNo_searchType: 'eq'
  },function(data){
	  var row = {pNo: projectRow.pNo};
	  if(data.length>0){
		  row = data[0];
	  }
	  pForm.loadData({formId:'workForm',data: row });
  });
  
  /*异步获取审计*/
  $.get('/console/com.fs.jzzn.pojo.Audit/json', {
	  pNo: projectRow.pNo,
	  pNo_searchType: 'eq'
  },function(data){
	  var row = {pNo: projectRow.pNo};
	  if(data.length>0){
		  row = data[0];
	  }
	  pForm.loadData({formId:'checkForm',data: row });
  });
  
  /*核减率计算*/
  $(".auditRate").on("input propertychange",function(){
	  var submitMoney = $("input[name=submitMoney]").val() ;
	  var auditMoney = $("input[name=auditMoney]").val() ;
	  submitMoney = parseFloat(submitMoney) || 0;
	  auditMoney = parseFloat(auditMoney) || 0;
	  if(submitMoney>0){
		 var p =  ( ((submitMoney-auditMoney)/submitMoney) *100 ).toFixed(2)+ '%' ;
		 $("input[name=auditRate]").val(p);
	  }else{
		  $("input[name=auditRate]").val(0);
	  }
  })
  
});
</script>
</body>
</html>